package io.renren.api.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.api.dao.BtCustomerMessageDao;
import io.renren.api.entity.BtCustomerMessageEntity;
import io.renren.api.service.BtCustomerMessageService;
import io.renren.utils.Query;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;


@Service("btCustomerMessageService")
public class BtCustomerMessageServiceImpl extends ServiceImpl<BtCustomerMessageDao, BtCustomerMessageEntity> implements BtCustomerMessageService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String cust_id = ( params.get("cust_id")).toString();
        String typestr = (String)params.get("tstr");
        Page<BtCustomerMessageEntity> page = this.selectPage(
                new Query<BtCustomerMessageEntity>(params).getPage(),
                new EntityWrapper<BtCustomerMessageEntity>().setSqlSelect("id,cust_id,typestr,title,img,summary,creattime,clickcnt").eq("typestr",typestr).eq(StringUtils.isNotEmpty(cust_id),"cust_id",cust_id)
        );

        return new PageUtils(page);
    }

}
